#include<string>  
#include<vector>  
#include<stack>  
#include<iostream>
  
using namespace std;  
class Solution
{
    bool isValid(string s)
    {
        stack<char> stk;
        for (char c : s)
        {
            if (c == '(' || c == '[' || c == '{')
            {
                stk.push(c);
            }
            else
            {
                if (stk.empty())
                    return false;
                char top = stk.top();
                stk.pop();
                if (c == ')' && top != '(')
                    return false;
                if (c == ']' && top != '[')
                    return false;
                if (c == '}' && top != '{')
                    return false;
            }
        }
        return stk.empty();
    }
};;
#ifndef COMPILER_ONLINE  
#include"header.cpp"  
#endif  
  
void Test1() {  
    Solution sol;  
    bool ret = sol.isValid("()");  
    if (ret) {  
        cout << "通过了用例1,测试()通过....OK!" << endl;  
    } else {  
        cout << "没有通过用例1,测试()失败....ERROR!" << endl;  
    }  
}  
  
int main() {  
    Test1();  
    return 0;  
}